package com.aaa.controller;

import com.aaa.entity.Role_fun;
import com.aaa.service.Role_funService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;

@RequestMapping("/rolefun")
@RestController
public class Role_funController {

    //业务层对象
    @Resource
    private Role_funService role_funService;

    /**
     * 批量添加
     * @param  对象
     * @return
     */
    @RequestMapping("add/{data}")
    public Integer add(@PathVariable("data") Integer[] fid,Integer rid){
//        return role_funService.add(rid,fid);
        System.out.println(Arrays.stream(fid).toArray());
        for (Integer i : fid) {
            System.out.println(i);
        }
        System.out.println(rid);
        Integer add = role_funService.add(rid, fid);
        System.out.println(add);
        return add;
    }

    /*@RequestMapping("/del2")
    public Integer del2(Integer rid){
        return 1;
    }*/
    @RequestMapping("/del")
    public Integer del(Integer rid){
        Integer result = role_funService.del(rid);
        return result;
    }
}
